home *** CD-ROM | disk | FTP | other *** search
/ APC & TCP 4 / APC & TCP 4.iso / games / publicdomain / a / asteroids2 / rotx / screen.c < prev    next >
C/C++ Source or Header  |  1995-07-20  |  16KB  |  758 lines

  1. #include <exec/types.h>
  2. #include <intuition/intuition.h>
  3. #include <graphics/gfxmacros.h>
  4. #include <graphics/displayinfo.h>
  5. #include <string.h>
  6. #include <h/rot.h>
  7. #include <h/extern.h>
  8. #include <h/define.h>
  9.  
  10. DefineKeys(wrp,window)
  11. struct RastPort *wrp;
  12. struct Window *window;
  13. {
  14. struct IntuiMessage *msg;
  15. LONG code=NULL;
  16. LONG x=0,i;
  17. BYTE string[10];
  18. LONG keycode[10];
  19. LONG x0,x1,x2,x3,yy[10],y0;
  20.  
  21. x0 = gi.wi/2-170;
  22. x1 = x0+12*(gi.smallfontheight-2);
  23. x2 = gi.wi/2+10;
  24. x3 = x2+12*(gi.smallfontheight-2);
  25.  
  26. y0 = gi.he/2-60;
  27. for(i=0;i<6;i++)
  28.     yy[i] = y0 + (gi.smallfontheight+2)*i;
  29.  
  30.  
  31. SetFont(wrp,basicfont);
  32. Move(wrp,gi.wi/2-135,110);
  33. Text(wrp,"DEFINE KEYS",11);
  34.  
  35.  
  36. SetFont(wrp,fixplain7font);
  37. Move(wrp,gi.wi/2-210,gi.he/2-80);
  38. Text(wrp,"CURRENT KEY DEFINITIONS",23);
  39.  
  40. SetFont(wrp,hiresfont);
  41. Move(wrp,x0,yy[0]);
  42. Text(wrp,"ROTATE LEFT",11);
  43. Move(wrp,x0,yy[1]);
  44. Text(wrp,"ROTATE RIGHT",12);
  45. Move(wrp,x0,yy[2]);
  46. Text(wrp,"FIRE",4);
  47. Move(wrp,x0,yy[3]);
  48. Text(wrp,"THRUST",6);
  49. Move(wrp,x0,yy[4]);
  50. Text(wrp,"HYPERSPACE",10);
  51. Move(wrp,x0,yy[5]);
  52. Text(wrp,"PAUSE",5);
  53.  
  54. sprintf(string,"$%x",k.left);
  55. Move(wrp,x1,yy[0]);
  56. Text(wrp,string,strlen(string));
  57. sprintf(string,"$%x",k.right);
  58. Move(wrp,x1,yy[1]);
  59. Text(wrp,string,strlen(string));
  60. sprintf(string,"$%x",k.fire);
  61. Move(wrp,x1,yy[2]);
  62. Text(wrp,string,strlen(string));
  63. sprintf(string,"$%x",k.thrust);
  64. Move(wrp,x1,yy[3]);
  65. Text(wrp,string,strlen(string));
  66. sprintf(string,"$%x",k.hyperspace);
  67. Move(wrp,x1,yy[4]);
  68. Text(wrp,string,strlen(string));
  69. sprintf(string,"$%x",k.pause);
  70. Move(wrp,x1,yy[5]);
  71. Text(wrp,string,strlen(string));
  72.  
  73. SetFont(wrp,fixplain7font);
  74. Move(wrp,gi.wi/2+5,gi.he/2-80);
  75. Text(wrp,"NEW KEY DEFINITIONS",19);
  76.  
  77. SetFont(wrp,hiresfont);
  78. Move(wrp,x2,yy[0]);
  79. Text(wrp,"ROTATE LEFT",11);
  80.  
  81. while ((code != F1) && (code != ESC))
  82. {
  83. WaitPort(window->UserPort);
  84. while (msg = (struct IntuiMessage *)GetMsg(window->UserPort))
  85.     {
  86.     code = msg->Code;
  87.     ReplyMsg((struct Message *)msg);
  88.     
  89.     if (code < 0x64)
  90.         {
  91.         x++;
  92.  
  93.         Move(wrp,x2,yy[x]);
  94.         if (x == 1)
  95.             {
  96.             Text(wrp,"ROTATE RIGHT",12);
  97.             keycode[0] = code;
  98.             }
  99.         else
  100.         if (x == 2)
  101.             {
  102.             Text(wrp,"FIRE",4);
  103.             keycode[1] = code;
  104.             }
  105.         else
  106.         if (x == 3)
  107.             {
  108.             Text(wrp,"THRUST",6);
  109.             keycode[2] = code;
  110.             }
  111.         else
  112.         if (x == 4)
  113.             {
  114.             Text(wrp,"HYPERSPACE",10);
  115.             keycode[3] = code;
  116.             }
  117.         else
  118.         if (x == 5)
  119.             {
  120.             Text(wrp,"PAUSE",5);
  121.             keycode[4] = code;
  122.             }
  123.         if (x == 6)
  124.             {
  125.             Move(wrp,gi.wi/2-110,gi.he/2+150);
  126.             Text(wrp,"PRESS < S >  TO SAVE DEFINITIONS",31);
  127.             Move(wrp,gi.wi/2-90,gi.he/2+150+gi.smallfontheight+2);
  128.             Text(wrp,"PRESS < F1 > TO RETURN",22);
  129.             keycode[5] = code;
  130.             }
  131.         if (x < 7)
  132.             {
  133.             Move(wrp,x3,yy[x-1]);
  134.             sprintf(string,"$%x",code);
  135.             Text(wrp,string,strlen(string));
  136.             }
  137.         else if (code == 0x21)
  138.                 {
  139.                 k.left = keycode[0]; 
  140.                 k.right = keycode[1]; 
  141.                 k.fire = keycode[2]; 
  142.                 k.thrust = keycode[3]; 
  143.                 k.hyperspace = keycode[4]; 
  144.                 k.pause = keycode[5]; 
  145.                 SaveKeyDefines();
  146.                 code = ESC;
  147.                 }
  148.         }
  149.     }
  150. }
  151. }
  152.  
  153.  
  154.  
  155. HandleOptions(wrp,window)
  156. struct RastPort *wrp;
  157. struct Window *window;
  158. {
  159. struct IntuiMessage *msg;
  160. LONG code=NULL,class;
  161. LONG x;
  162. BYTE string[10];
  163. LONG y1,yy[20],x0,x1,x2,x3;
  164. LONG screentype;
  165.  
  166. x0 = gi.wi/2 - 22*(gi.smallfontheight-2);
  167. x1 = x0 + 5*(gi.mediumfontheight-2);
  168. x2 = x1 + 22*(gi.smallfontheight-2);
  169. x3 = x2 + 25*(gi.smallfontheight-2);
  170.  
  171. y1 = 100;
  172. for(x=0;x<20;x++) 
  173.     yy[x] = y1+40+(gi.mediumfontheight+3)*x;
  174.  
  175.  
  176. SetFont(wrp,basicfont);
  177. Move(wrp,gi.wi/2-90,y1);
  178. Text(wrp,"OPTIONS",7);
  179.  
  180.  
  181. SetFont(wrp,fixplain7font);
  182.  
  183.  
  184. Move(wrp,x0,yy[0]);
  185. Text(wrp,"<F1>",4);
  186. Move(wrp,x0,yy[1]);
  187. Text(wrp,"<F2>",4);
  188. Move(wrp,x0,yy[2]);
  189. Text(wrp,"<F3>",4);
  190. Move(wrp,x0,yy[3]);
  191. Text(wrp,"<F4>",4);
  192. Move(wrp,x0,yy[4]);
  193. Text(wrp,"<F5>",4);
  194. Move(wrp,x0,yy[5]);
  195. Text(wrp,"<F6>",4);
  196. Move(wrp,x0,yy[6]);
  197. Text(wrp,"<F7>",4);
  198. Move(wrp,x0,yy[7]);
  199. Text(wrp,"<F8>",4);
  200. Move(wrp,x0,yy[8]);
  201. Text(wrp,"<F9>",4);
  202. Move(wrp,x0,yy[9]);
  203. Text(wrp,"<F10>",5);
  204.  
  205. Move(wrp,x0,yy[11]);
  206. Text(wrp,"<L>",3);
  207. Move(wrp,x0,yy[12]);
  208. Text(wrp,"<D>",3);
  209. Move(wrp,x0,yy[13]);
  210. Text(wrp,"<G>",3);
  211. Move(wrp,x0,yy[14]);
  212. Text(wrp,"<T>",3);
  213. Move(wrp,x0,yy[15]);
  214. Text(wrp,"<F>",3);
  215. Move(wrp,x0,yy[17]);
  216. Text(wrp,"<S>",3);
  217.  
  218. Move(wrp,x1,yy[0]);
  219. Text(wrp,"TO RETURN",9);
  220.  
  221.  
  222.  
  223. SetFont(wrp,hiresfont);
  224. Move(wrp,x1,yy[1]-1);
  225. Text(wrp,"NUMBER OF PLAYERS--",19);
  226. Move(wrp,x2,yy[1]-1);
  227. sprintf(string,"%d",control.playernum);
  228. Text(wrp,string,strlen(string));
  229.  
  230.  
  231. SetFont(wrp,hiresfont);
  232. Move(wrp,x1,yy[2]-1);
  233. Text(wrp,"PLAYER ONE CONTROL--",20);
  234. Move(wrp,x2,yy[2]-1);
  235. if (control.input[0] == 0) Text(wrp,"HUMAN (KEYBOARD)",16);
  236. else
  237. if (control.input[0] == 1) Text(wrp,"HUMAN (JOYSTICK)",16);
  238.  
  239.  
  240. Move(wrp,x1,yy[3]-1);
  241. Text(wrp,"PLAYER TWO CONTROL--",20);
  242. Move(wrp,x2,yy[3]-1);
  243. if (control.input[1] == 0) Text(wrp,"HUMAN (KEYBOARD)",16);
  244. else
  245. if (control.input[1] == 1) Text(wrp,"HUMAN (JOYSTICK)",16);
  246.  
  247.  
  248. Move(wrp,x1,yy[4]-1);
  249. Text(wrp,"MAXIMUM ENEMY SHIPS--",21);
  250. Move(wrp,x2,yy[4]-1);
  251. sprintf(string,"%d",control.enemyonscreen);
  252. Text(wrp,string,strlen(string));
  253.  
  254. Move(wrp,x1,yy[5]-1);
  255. Text(wrp,"FIGHTERS IN SQUADRON--",22);
  256. Move(wrp,x2,yy[5]-1);
  257. sprintf(string,"%d",control.ftrnum);
  258. Text(wrp,string,strlen(string));
  259.  
  260. Move(wrp,x1,yy[6]-1);
  261. Text(wrp,"BASE GAME DELAY--",17);
  262. Move(wrp,x2,yy[6]-1);
  263. sprintf(string,"%d",control.delay);
  264. Text(wrp,string,strlen(string));
  265.  
  266. Move(wrp,x1,yy[7]-1);
  267. Text(wrp,"TEAM PLAY MODE--",16);
  268. Move(wrp,x2,yy[7]-1);
  269. if (control.playmode == 0) Text(wrp,"COOPERATIVE",11);
  270. else
  271. if (control.playmode == 1) Text(wrp,"COMPETITIVE",11);
  272.  
  273. Move(wrp,x1,yy[8]-1);
  274. Text(wrp,"AMOUNT OF DEBRIS--",18);
  275. Move(wrp,x2,yy[8]-1);
  276. sprintf(string,"%d",control.standarddebris);
  277. Text(wrp,string,strlen(string));
  278.  
  279. Move(wrp,x1,yy[9]-1);
  280. Text(wrp,"FIRE WRAP --",12);
  281. Move(wrp,x2,yy[9]-1);
  282. if (control.firewrap == FALSE) Text(wrp,"OFF",3);
  283. else                         Text(wrp,"ON",2);
  284.  
  285.  
  286.  
  287. Move(wrp,x1,yy[11]-1);
  288. Text(wrp,"START LEVEL-",12);
  289. Move(wrp,x2,yy[11]-1);
  290. sprintf(string,"%d",control.startlevel);
  291. Text(wrp,string,strlen(string));
  292.  
  293. Move(wrp,x1,yy[12]-1);
  294. Text(wrp,"DIFFICULTY--",12);
  295. Move(wrp,x2,yy[12]-1);
  296. if (control.difficulty == 0) Text(wrp,"SIMPLE",6);
  297. else
  298. if (control.difficulty == 1) Text(wrp,"PRACTICE",8);
  299. else
  300. if (control.difficulty == 2) Text(wrp,"NORMAL",6);
  301.  
  302. Move(wrp,x1,yy[13]-1);
  303. Text(wrp,"GAME --",7);
  304. Move(wrp,x2,yy[13]-1);
  305.  
  306.  
  307. #if REGISTERED == TRUE
  308. if (control.game == 0) Text(wrp,"ASTERIODS II",12);
  309. #else
  310. if (control.game == 0) Text(wrp,"LIMITED ASTERIODS II",20);
  311. #endif
  312. else                   Text(wrp,"BASIC ASTEROIDS",15);
  313.  
  314.  
  315. screentype = control.screentype;
  316. Move(wrp,x1,yy[14]-1);
  317. Text(wrp,"SCREEN TYPE--",12);
  318. Move(wrp,x2,yy[14]-1);
  319. if (control.screentype == 0) Text(wrp,"WORKBENCH CLONE",15);
  320. else
  321. if (control.screentype == 1) Text(wrp,"HIRES NTSC",10);
  322. else
  323. if (control.screentype == 2) Text(wrp,"HIRES PAL",9);
  324. else
  325. if (control.screentype == 3) Text(wrp,"SUPERHIRES NTSC",15);
  326. else
  327. if (control.screentype == 4) Text(wrp,"SUPERHIRES PAL",14);
  328.  
  329.  
  330. Move(wrp,x1,yy[15]-1);
  331. Text(wrp,"FONT SIZE--",11);
  332. Move(wrp,x2,yy[15]-1);
  333. if (control.fontsize == 0) Text(wrp,"SMALL",5);
  334. else
  335. if (control.fontsize == 1) Text(wrp,"LARGE",5);
  336.  
  337.  
  338. Move(wrp,x1,yy[17]-1);
  339. Text(wrp,"SAVE OPTIONS TO DISK",20);
  340. Move(wrp,x2,yy[17]-1);
  341.  
  342.  
  343. while ((code != F1) && (code != ESC))
  344. {
  345. WaitPort(window->UserPort);
  346. while (msg = (struct IntuiMessage *)GetMsg(window->UserPort))
  347.     {
  348.     class = msg->Class;
  349.     code = msg->Code;
  350.     ReplyMsg((struct Message *)msg);
  351.  
  352.     if (class == RAWKEY)
  353.     {
  354.  
  355.     if (code == F2)
  356.         {
  357.          SetAPen(wrp,0);
  358.          RectFill(wrp,x2-1,yy[1]-(gi.smallfontheight+1),x3,yy[1]);
  359.         SetAPen(wrp,1);
  360.         Move(wrp,x2,yy[1]-1);
  361.          if (++control.playernum > control.maxplayernum) control.playernum = 1;
  362.         sprintf(string,"%d",control.playernum);
  363.         Text(wrp,string,strlen(string));
  364.  
  365.         Delay(10);
  366.         }
  367.     else
  368.     if (code == F3)
  369.         {
  370.          SetAPen(wrp,0);
  371.          RectFill(wrp,x2-1,yy[2]-(gi.smallfontheight+1),x3,yy[2]);
  372.         SetAPen(wrp,1);
  373.         Move(wrp,x2,yy[2]-1);
  374.  
  375.          if (++control.input[0] > 1) control.input[0] = 0;
  376.  
  377.          if (control.input[0] == 0) Text(wrp,"HUMAN (KEYBOARD)",16);
  378.         else
  379.         if (control.input[0] == 1) Text(wrp,"HUMAN (JOYSTICK)",16);
  380.         Delay(10);
  381.         }
  382.     else
  383.     if (code == F4)
  384.         {
  385.         SetAPen(wrp,0);
  386.          RectFill(wrp,x2-1,yy[3]-(gi.smallfontheight+1),x3,yy[3])